//
//  UIImage+scale.m
//  MegFaceClusteringDemo
//
//  Created by Megvii on 2019/11/25.
//  Copyright © 2019 tongshasha. All rights reserved.
//

#import "UIImage+scale.h"


@implementation UIImage (scale)

- (UIImage *)scaleToSize:(CGSize)size {
    //开启图片上下文
    UIGraphicsBeginImageContext(size);
    //渲染到上下文
    [self drawInRect:CGRectMake(0, 0, size.width, size.height)];
    //上下文获取图片
    UIImage *endImage = UIGraphicsGetImageFromCurrentImageContext();
    //关闭上下文
    UIGraphicsEndImageContext();
    return endImage;
}

@end
